package com.wty.cmims.controller;

import com.wty.cmims.pojo.ResponseResult;
import com.wty.cmims.service.PermissionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/permission")
@Tag(name = "权限信息", description = "社区医疗信息后台管理系统api接口")
public class PermissionController {
    @Autowired
    private PermissionService permissionService;

    // 根据user_id获取权限信息
    @PostMapping("/findPermissionById/{id}")
    @Operation(summary = "权限信息获取", description = "权限信息获取")
    @Parameter(name = "user_id",description = "账号ID")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Map<String,Object>> findPermission(@PathVariable("id") Integer id){
        return permissionService.findPermission(id);
    }

    // 权限启停
    @PostMapping("/updatePermission")
    @Operation(summary = "权限启停", description = "权限启停")
    @Parameter(name = "paramsMap",description = "参数列表")
    @ApiResponse(description = "处理结果",content = {
            @Content(
                    mediaType="application/json",
                    schema= @Schema(implementation = ResponseResult.class)
            )
    })
    public ResponseResult<Void> updatePermission(@RequestBody Map<String,Object> paramsMap){
        return permissionService.updatePermission(paramsMap);
    }
}